﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DALScolarite;
namespace DALScolarite 
{
    public partial class scolarite_inscription  
    {
        uvtmoyEntities ent;

        

        public scolarite_inscription VerifInscripton(long idetudiants, string varidAnneeUniv)
        {
              ent = new uvtmoyEntities();
            var query = (from s in ent.scolarite_inscription
                     where s.idetudiants == idetudiants && s.idAnneeUniv == varidAnneeUniv
                     select s);
            if (query.Any())
            {
                scolarite_inscription res = query.First();
                return res;
            }
            else
            {
                return null;
            }


        }

        public List<EtudiantsInscript> EtudiantNonAffecteraUngroupe(string iddiplome, string idclasse, string idanneeuniv)
        {
            ent = new uvtmoyEntities();
            var query =  from s in ent.scolarite_inscription
                         join e in ent.scolarite_etudiants on s.idetudiants equals e.idetudiants 
                         where s.idEltDiplome == iddiplome && s.idClasse == idclasse && s.idAnneeUniv == idanneeuniv && !(from inscgroup in ent.scolarite_inscriptgroupeclass select inscgroup.idInscription).Contains(s.idInscription)
                         

                         orderby e.NomFR, e.PrenomFR
                         select new EtudiantsInscript()  { 
                               idetudiants = e.idetudiants,
                              idInscription = s.idInscription,
                              NomFR = e.NomFR,
                              PrenomFR = e.PrenomFR,
                              email = e.email,
                              sex = e.sex,
                              cin = e.cin
                             }
                          ;
             

                return query.ToList();
            
        }

    }
}
